package com.ben.chatroom.protoBuilder;

import com.ben.chatroom.common.ProInstant;
import com.ben.chatroom.common.entity.ProtoMsg;

/**
 * @author huangyijun
 */
public class LoginResponseBuilder {

  public static ProtoMsg.Message loginResponse(ProInstant.ResultCode resultCode, long seqId, String sessionId) {
    ProtoMsg.Message.Builder mb = ProtoMsg.Message
      .newBuilder()
      .setType(ProtoMsg.HeadType.LOGIN_RESPONSE)
      .setSequence(seqId)
      .setSessionId(sessionId);

    ProtoMsg.LoginResponse.Builder response = ProtoMsg.LoginResponse
      .newBuilder()
      .setCode(resultCode.getCode())
      .setInfo(resultCode.getDesc())
      .setExpose(1);

    return mb.setLoginResponse(response.build()).build();
  }

}
